home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / wireless-tools < prev    next >
Encoding:
Text File  |  2010-11-16  |  4.6 KB  |  181 lines

  1. # bash completion for Linux wireless-tools
  2.  
  3. [ $UNAME = Linux ] &&
  4. {
  5.  
  6. have iwconfig &&
  7. _iwconfig()
  8. {
  9.     local cur prev
  10.  
  11.     COMPREPLY=()
  12.     _get_comp_words_by_ref cur prev
  13.  
  14.     case $prev in
  15.         mode)
  16.             COMPREPLY=( $( compgen -W 'managed ad-hoc master \
  17.                 repeater secondary monitor' -- "$cur" ) )
  18.             return 0
  19.             ;;
  20.         essid)
  21.             COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
  22.             if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
  23.                 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
  24.                     "$( iwlist ${COMP_WORDS[1]} scan | \
  25.                     awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) )
  26.             fi
  27.             return 0
  28.             ;;
  29.         nwid)
  30.             COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
  31.             return 0
  32.             ;;
  33.         channel)
  34.             COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
  35.                 awk '/^[ \t]*Channel/ {print $2}' )" -- "$cur" ) )
  36.             return 0
  37.             ;;
  38.  
  39.         freq)
  40.             COMPREPLY=( $( compgen -W "$( iwlist ${COMP_WORDS[1]} channel | \
  41.                 awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur" ) )
  42.             return 0
  43.             ;;
  44.         ap)
  45.             COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
  46.             if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
  47.                 COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
  48.                     "$( iwlist ${COMP_WORDS[1]} scan | \
  49.                     awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) )
  50.             fi
  51.             return 0
  52.             ;;
  53.         rate)
  54.             COMPREPLY=( $( compgen -W 'auto fixed' -- "$cur" ) )
  55.             COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
  56.                 "$( iwlist ${COMP_WORDS[1]} rate | \
  57.                 awk '/^[ \t]*[0-9]/ {print $1"M"}' )" -- "$cur" ) )
  58.             return 0
  59.             ;;
  60.         rts|frag)
  61.             COMPREPLY=( $( compgen -W 'auto fixed off' -- "$cur" ) )
  62.             return 0
  63.             ;;
  64.         key|enc)
  65.             COMPREPLY=( $( compgen -W 'off on open restricted' -- "$cur" ) )
  66.             return 0
  67.             ;;
  68.         power)
  69.             COMPREPLY=( $( compgen -W 'period timeout off on' -- "$cur" ) )
  70.             return 0
  71.             ;;
  72.         txpower)
  73.             COMPREPLY=( $( compgen -W 'off on auto' -- "$cur" ) )
  74.             return 0
  75.             ;;
  76.         retry)
  77.             COMPREPLY=( $( compgen -W 'limit lifetime' -- "$cur" ) )
  78.             return 0
  79.             ;;
  80.     esac
  81.  
  82.     if [ $COMP_CWORD -eq 1 ]; then
  83.         if [[ "$cur" == -* ]]; then
  84.             COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
  85.         else
  86.             _available_interfaces -w
  87.         fi
  88.     else
  89.         COMPREPLY=( $( compgen -W 'essid nwid mode freq channel sens mode \
  90.             ap nick rate rts frag enc key power txpower commit' -- "$cur" ) )
  91.     fi
  92.  
  93. } &&
  94. complete -F _iwconfig iwconfig
  95.  
  96.  
  97. have iwlist &&
  98. _iwlist()
  99. {
  100.     local cur prev
  101.  
  102.     COMPREPLY=()
  103.     _get_comp_words_by_ref cur prev
  104.  
  105.     if [ $COMP_CWORD -eq 1 ]; then
  106.         if [[ "$cur" == -* ]]; then
  107.             COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
  108.         else
  109.             _available_interfaces -w
  110.         fi
  111.     else
  112.         COMPREPLY=( $( compgen -W 'scan scanning freq frequency \
  113.             channel rate bit bitrate key enc encryption power \
  114.             txpower retry ap accesspoint peers event' -- "$cur" ) )
  115.     fi
  116. } &&
  117. complete -F _iwlist iwlist
  118.  
  119.  
  120. have iwspy &&
  121. _iwspy()
  122. {
  123.     local cur
  124.  
  125.     COMPREPLY=()
  126.     _get_comp_words_by_ref cur
  127.  
  128.     if [ $COMP_CWORD -eq 1 ]; then
  129.         if [[ "$cur" == -* ]]; then
  130.             COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
  131.         else
  132.             _available_interfaces -w
  133.         fi
  134.     else
  135.         COMPREPLY=( $( compgen -W 'setthr getthr off' -- "$cur" ) )
  136.     fi
  137. } &&
  138. complete -F _iwspy iwspy
  139.  
  140.  
  141. have iwpriv &&
  142. _iwpriv()
  143. {
  144.     local cur prev
  145.  
  146.     COMPREPLY=()
  147.     _get_comp_words_by_ref cur prev
  148.  
  149.     case $prev in
  150.         roam)
  151.             COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
  152.             return 0
  153.             ;;
  154.         port)
  155.             COMPREPLY=( $( compgen -W 'ad-hoc managed' -- "$cur" ) )
  156.             return 0
  157.             ;;
  158.     esac
  159.  
  160.     if [ $COMP_CWORD -eq 1 ]; then
  161.         if [[ "$cur" == -* ]]; then
  162.             COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
  163.         else
  164.             _available_interfaces -w
  165.         fi
  166.     else
  167.         COMPREPLY=( $( compgen -W '--all roam port' -- "$cur" ) )
  168.     fi
  169. } &&
  170. complete -F _iwpriv iwpriv
  171.  
  172. }
  173.  
  174. # Local variables:
  175. # mode: shell-script
  176. # sh-basic-offset: 4
  177. # sh-indent-comment: t
  178. # indent-tabs-mode: nil
  179. # End:
  180. # ex: ts=4 sw=4 et filetype=sh
  181.